-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add: validation of bundled themes in build workflow #11627
Add: validation of bundled themes in build workflow #11627
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that we refactor Theme::load
to return a Vec
of any warnings (so basically Result<(Theme, Vec<String>)>
). The current callers of Theme::load
can then log the warnings and the xtask can print them and error out.
For the themes that currently fail to pass this we can comment out the offending keys and link to the issue. They're basically discarded while loading so commenting them out should be equivalent |
Updated the implementation to explicitly return validation failures rather than use log captures. This involved adding a new public factory constructor on the Please let me know if I've misunderstood what you were suggesting! EDIT: I see now that we need to update the loader in order to correctly handle inherited styles and palette colours. Will update |
I've updated the implementation to return both the theme and any validation failures from the The Let me know what you think @the-mikedavis |
helix-view/src/theme.rs
Outdated
@@ -52,21 +52,24 @@ impl Loader { | |||
} | |||
|
|||
/// Loads a theme searching directories in priority order. | |||
pub fn load(&self, name: &str) -> Result<Theme> { | |||
pub fn load(&self, name: &str) -> Result<(Theme, Vec<String>)> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have many callers that need to handle the warnings let's create a load_with_warnings
helper that has this function's body and then load
can call that helper and log the warnings.
…ogging of theme warnings
let (theme, warnings) = self.load_with_warnings(name)?; | ||
|
||
for warning in warnings { | ||
warn!("Theme '{}': {}", name, warning); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging theme name along with warning
Introduced helper method as suggested. Now that the warnings are being logged in the same place, I updated the warning messages to include the theme name to make it clearer to users which theme is the source of the warning |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'm looking forward to this - I always pull down a theme PR and run it and look at the log and automating this step will be nice
* Add: xtask to check themes for validation warnings * Update: tidied up runtime paths * Update: test build workflow * Update: address clippy lints * Revert: only trigger workflow on push to master branch * Add: Theme::from_keys factory method to construct theme from Toml keys * Update: returning validation failures in Loader.load method * Update: commented out invalid keys from affected themes * Update: correct invalid keys so that valid styles still applied * Update: include default and base16_default themes in check * Update: renamed validation_failures to load_errors * Update: introduce load_with_warnings helper function and centralise logging of theme warnings * Update: use consistent naming throughout
Added xtask to validate bundled themes in order to detect issues at build time. Basically just loading all the themes are surfacing any warning logs which are emitted.
Main issue with the current implementation in the CI workflow is that it will cause builds on master to fail until the theme validation issues are addressed by their respective maintainers. Alternatively we could add a separate GitHub workflow which only triggers when the
runtime/themes
directory is edited but this felt like overkill in this instance.Add: xtask for validating bundled themes
Update: build workflow to run theme validation on build
Closes #5709